<template>
<!-- 党组织列表页 -->
  <div>
      <el-button v-show="showaddButton" type="primary" class="builtactive" @click="AddParty">新建党组织</el-button>
      <el-table class="parttable" :data="OrganizationList" height="560" border>
        <el-table-column
          prop="name"
          label="党组织名称">
        </el-table-column>
        <el-table-column
          prop="academyName"
          label="所在院系">
        </el-table-column>
        <el-table-column
          prop="createTime"
          label="创建时间">
        </el-table-column>
      </el-table>
      <partyAdd @Organization="Organization" v-show="showParty" ref="part"></partyAdd>
  </div>
</template>
<script>
// import axios from "axios"
import partyAdd from "./partyAdd.vue"
export default {
  components:{
    partyAdd
  },
  data(){
    return{
      OrganizationList:[],//党组织列表
      showParty:false,//是否显示新增活动弹窗
      showaddButton:true,//是否显示新增党组织按钮
    }
  },
  mounted(){
    this.Organization()
    var authority = JSON.parse(localStorage.getItem('userinfo'))
    if(authority.authority.length==0||authority.authority[0].authority == "dc"){
      this.showaddButton = false
    }
  },
  methods:{
    Organization(){//获取党组织列表
      this.axios({
        headers:{'Authentication':localStorage.getItem('token')},
        method:"get",
        // url:"api/organization/getOrganizationList",
        url:"/organization/getOrganizationList",
      }).then(res=>{
        // console.log(res)
        if(res.data.code != 20001){
          return this.$message.error(res.data.msg)
        }
        else{
          this.OrganizationList = res.data.data
        }
      })
    },
    AddParty(){//点击新建党组织按钮
      this.showParty = true
      this.$nextTick(() => {
        this.$refs.part.init(this.OrganizationList)
      })
    }
  }
}
</script>

<style lang="scss">
.parttable{
  margin-top: 2vh;
  th,td{
    text-align: center;
  }
}
</style>